package lingnan.cn.edu.filter;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import lingnan.cn.edu.util.DbAccess;

public class Filter {
	 public int filter(String staffName) {
		Connection conn = null;
		PreparedStatement prep = null;
		ResultSet rs = null;
		try {
			conn = DbAccess.getConnection();		
			prep = conn.prepareStatement("select super from staff where staffName = ?");
			prep.setString(1, staffName);
			rs = prep.executeQuery();
			if(rs.next()) {
				if(rs.getInt("super")==1)
					return 1;
				else if(rs.getInt("super")==2)
					return 2;
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				if(conn!=null)
					conn.close();
				if(rs!=null)
					rs.close();
				if(prep!=null)
					prep.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return 0;
		
	}
}
